package com.freedy.concurrent.Monitors.sharingProblem;

import lombok.extern.slf4j.Slf4j;

/**
 * 线程八锁
 * 情况4：2 1s 后 1
 * @author Freedy
 * @date 2021/4/20 22:48
 */
public class Test7 {
    public static void main(String[] args) {
        Number3 n1 = new Number3();
        Number3 n2 = new Number3();
        new Thread(()->{ n1.a(); }).start();
        new Thread(()->{ n2.b(); }).start();
    }
}

@Slf4j
class Number3{
    public synchronized void a() {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.debug("1");
    }
    public synchronized void b() {
        log.debug("2");
    }
}